<?php

    ### ########################################################################
    ###         WEBAPP BOOTSTRAP FILE
    ### ########################################################################

    ini_set('display_errors', 1);
    error_reporting(E_ALL);

    require_once 'phar://PHP-INF/libs/core-1.0.phar/index.php';
    require_once 'phar://PHP-INF/libs/validator-1.0.phar/index.php';
    require_once 'phar://PHP-INF/libs/page-1.0.phar/index.php';

    use eu\freeplace\core\ConfigurationLoader   as ConfigurationLoader;
    use eu\freeplace\core\CodeCompressor        as CodeCompressor;
    use eu\freeplace\core\Logger                as Logger;
    use eu\freeplace\core\Utils      		as Utils;
    use eu\freeplace\validator\Validator  	as Validator;
    use eu\freeplace\page\Document 		as Document;


    $appConfig = ConfigurationLoader::getInstance();
    $config = $appConfig->loadConfiguration();

    $logger 	= Logger::getInstance();
    $utils  	= Utils::getInstance();
    $validator 	= Validator::getInstance();

    try {
        $logger->log("ConfigurationLoader.getAppConfiguration() :: ".sizeof($config)." MAIN config Items readed.", "DEBUG");
        $logger->log("###### START REQUEST ######", "NOTICE");

        //CONNECT the DATABASE
        $dbh = $utils->connectDB();

        $contentID = 0;
        
        //DOCUMENT
        $document = new Document();
        $out = $document->drawDocument($contentID);

        //DISCONNECT FROM DATABASE
        $utils->closeDB($dbh);

        $logger->log("####### END REQUEST #######\n\n", "NOTICE");

        echo $out;
    } catch(Exception $e) {

        $logger->log($e->getMessage(), "ERROR");
    }

?>
